﻿using System;
using System.Collections.Generic;

namespace Phoenix.Xna.Framework
{
    public class ValueBindingCollection : List<ValueBinding>
    {
        public ValueBinding this[string id]
        {
            get { return FirstOf(id); }
            set
            {
                ValueBinding b = FirstOf(id);

                if (b != null)
                {
                    b = value;
                }

                // TODO : add exception message
                throw new IndexOutOfRangeException();
            }
        }

        public bool Contains(string id)
        {
            foreach (ValueBinding b in this)
            {
                if (string.Compare(b.ID, id) == 0)
                {
                    return true;
                }
            }

            return false;
        }

        public ValueBinding FirstOf(string id)
        {
            foreach (ValueBinding b in this)
            {
                if (string.Compare(b.ID, id) == 0)
                {
                    return b;
                }
            }

            return null;
        }

        public void LoadContent()
        {
            foreach (ValueBinding v in this)
            {
                v.LoadContent();
            }
        }
    }
}
